package com.typhoon.spring_boot_demo1.proccessor;

import com.typhoon.spring_boot_demo1.exception.UserException;
import com.typhoon.spring_boot_demo1.request.UserOptContext;
import com.typhoon.spring_boot_demo1.utils.ParameterChecker;
import org.springframework.stereotype.Component;

/**
 * 新增
 *
 */
@Component
public class InsertUserOperation extends AbstractUserOperation {
    @Override
    public void execute(UserOptContext context) throws UserException {
        this.userDao.create(context.getName(),context.getSex(),context.getAge());
    }

    @Override
    public void checkParameter(UserOptContext context) throws UserException {
        ParameterChecker.checkNotNull(context,"context");
        ParameterChecker.checkNotNull(context.getName(),"name");
        ParameterChecker.checkNotNull(context.getAge(),"age");
    }
}
